
import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:amap_flutter_search/src/entity/poi.dart';

class PoiAddress {
  String? neighborhood;
  String? building;
  String? province;
  String? countryCode;
  String? city;
  String? citycode;
  String? district;
  String? adcode;
  StreetNumber? streetNumber;
  String? country;
  String? township;
  String? towncode;

  PoiAddress(
      {this.neighborhood,
        this.building,
        this.province,
        this.countryCode,
        this.city,
        this.citycode,
        this.district,
        this.adcode,
        this.streetNumber,
        this.country,
        this.township,
        this.towncode});

  PoiAddress.fromJson(Map<String, dynamic> json) {
    neighborhood = json['neighborhood'];
    building = json['building'];
    province = json['province'];
    countryCode = json['countryCode'];
    city = json['city'];
    citycode = json['citycode'];
    district = json['district'];
    adcode = json['adcode'];
    streetNumber = json['streetNumber'] != null
        ? StreetNumber.fromJson(json['streetNumber'])
        : null;
    country = json['country'];
    township = json['township'];
    towncode = json['towncode'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['neighborhood'] = this.neighborhood;
    data['building'] = this.building;
    data['province'] = this.province;
    data['countryCode'] = this.countryCode;
    data['city'] = this.city;
    data['citycode'] = this.citycode;
    data['district'] = this.district;
    data['adcode'] = this.adcode;
    if (this.streetNumber != null) {
      data['streetNumber'] = this.streetNumber!.toJson();
    }
    data['country'] = this.country;
    data['township'] = this.township;
    data['towncode'] = this.towncode;
    return data;
  }
}

class StreetNumber {
  String? direction;
  String? number;
  String? street;
  LatLng? location;
  num? distance;

  StreetNumber(
      {this.direction, this.number, this.street, this.location, this.distance});

  StreetNumber.fromJson(Map<String, dynamic> json) {
    direction = json['direction'];
    number = json['number'];
    street = json['street'];
    location = NLatLng.from(json['location']);
    distance = json['distance'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['direction'] = direction;
    data['number'] = number;
    data['street'] = street;
    if (location != null) {
      data['location'] = location!.toJson();
    }
    data['distance'] = distance;
    return data;
  }
}
